<include file='Common:head'/>
<form action="" id="upForm">
	<div class="opinion_box box2">
		<div class="div name">
			聯&nbsp;&nbsp;&nbsp;繫&nbsp;&nbsp;&nbsp;人&nbsp;:&nbsp;
			<input type="text" name="contact" placeholder="請輸入聯繫人"/>
		</div>
		<div class="div phone">
			聯&nbsp;繫&nbsp;電&nbsp;話&nbsp;:&nbsp;
			<input type="text" name="contact_phone" placeholder="請輸入聯繫電話"/>
		</div>
		<div class="div content">
			意見建議:
			<br/>
			<textarea name="content" placeholder="請輸入建議"/></textarea>
		<div class="div button">
			<input type="button" value="提 交" onclick="javascript:savesuggest();" />
		</div>
	</div>
</form>

<script type="text/javascript">
$(document).ready(function(){
	$('title').html('個人中心');
	$('.header .title').html('意見建議');
	$('.header .left').html('<img src="__PRIVATE__/images/left.png" style="width:55%"/>');
	$('.header .right').html('');
	$('.header .left').click(function(){
		window.location.href = "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/my')}";
	});

});

//保存建議
function savesuggest(){
	if ($('input[name=contact]').val() =='' || $('input[name=contact_phone]').val() =='' || $('textarea[name=content]').val() =='') {
			layer.open({
			    content: '請填寫數據'
			    ,skin: 'msg'
			    ,style: 'width: 30%; height:5%;padding:20px;font-size:3rem;'
			    ,time: 1 //2秒后自动关闭
			});
		return false;
	}
	var formData = $('#upForm').serialize()
	$.ajax({
		url:"{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/add_opinion')}",
		type: 'POST',
        data : formData,
        async: false,
		dataType: 'json',
		success:function(data){
			if (data.status == 1){
				layer.open({
					    content: data.info
					    ,skin: 'msg'
					    ,style: 'width: 30%; height:5%;padding:20px;font-size:3rem;'
					    ,time: 1 //2秒后自动关闭
					    ,end: function () {
							location.href = "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/"+data.url+"')}";
						}
					});
    		}
			else{
				alert(456);
    		}
		}
	});

}
</script>
<include file='Common:footer'/>
